<%= form_for [refinery, :portfolio_admin, @gallery] do |f| -%>
  <%= render :partial => "/refinery/admin/error_messages", :locals => {
          :object => @gallery,
          :include_object_name => true
        } %>

  <%= render :partial => "refinery/portfolio/admin/shared/locale_picker",
             :locals => {
               :current_locale => Thread.current[:globalize_locale]
             } if defined?(::Refinery::I18n) %>
  
  <div class='field'>
    <%= f.label :title -%>
    <%= f.text_field :title, :class => 'larger widest'  -%>
  </div>
  
  <div class='field'>
    <div id='page-tabs' class='clearfix ui-tabs ui-widget ui-widget-content ui-corner-all'>
      <ul id='page_parts'>
        <% [:body].each_with_index do |part, part_index| %>
          <li class='ui-state-default<%= ' ui-state-active' if part_index == 0 %>'>
            <%= link_to t("#{part}", :scope => "activerecord.attributes.refinery/portfolio/gallery", :default => part.to_s.titleize), "##{part}" %>
          </li>
        <% end %>
        <li class='ui-state-default'>
          <%= link_to t('.images'), "#images" %>
        </li>
      </ul>
      <div id='page_part_editors'>
        <% [:body].each do |part| %>
          <div class='page_part' id='<%= part %>'>
            <%= f.text_area part, :rows => 20, :class => 'wymeditor widest' -%>
          </div>
        <% end %>
        <div class='page_part' id='images'>
          <%= render :partial => 'image_fields', :locals => {:f => f} %>
        </div>
      </div>
    </div>
  </div>
  
  <div class='field'>
    <span class='label_with_help'>
      <%= f.label :parent_id, t('.parent_gallery') -%>
      <%= refinery_help_tag t('.parent_gallery_help') -%>
    </span>
    <%= f.select :parent_id, nested_set_options(::Refinery::Portfolio::Gallery, @gallery) {|i| "#{'-' * i.level} #{i.title}" }, :include_blank => true %>
  </div>

  <%= render :partial => "/refinery/admin/form_actions",
              :locals => {
                :f => f,
                :continue_editing => false,
                :delete_title => t('delete', :scope => 'refinery.portfolio.admin.galleries.gallery'),
                :delete_confirmation => t('message', :scope => 'refinery.admin.delete', :title => @gallery.title)
              } %>
<% end -%>
<% content_for :javascripts, javascript_include_tag('refinery/portfolio/admin/portfolio') %>
<% content_for :stylesheets, stylesheet_link_tag('refinery/portfolio/admin/galleries') %>
